package org.zsk.fastdev.annotations.enumration;

import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * <p>
 *     sql比较符号与方法
 * </p>
 *
 * @author zsk
 * @version 1.0
 * Created on 2020/5/29
 */
@Getter
public enum SqlComparator {
    EQ("eq","="),
    GT("gt",">"),
    GE("ge",">="),
    LT("lt","<"),
    LE("le","<="),
    LIKE("like","like");

    /**
     * 方法
     */
    private String method;
    /**
     * 符号
     */
    private String symbol;
    SqlComparator(String method,String symbol){
        this.method=method;
        this.symbol=symbol;
    }

    /**
     * 符号转方法
     * @param symbol 符号
     * @return 符号对应的方法
     */
    public static String symbol2Method(String symbol){
        List<String> method=Arrays.stream(SqlComparator.values()).filter(sqlComparator -> {
            return symbol.equals(sqlComparator.getSymbol());
        }).map(SqlComparator::getMethod).collect(Collectors.toList());
        return method.get(0);
    }
}
